﻿using System;
using System.Web;
using C3.Proto.Core.Model;
using C3.Proto.Core.Service;

namespace C3.Safety.Service
{

    public class SessionService : ISessionService
    {
        private const string UserKey = "User";
        public User GetUser()
        {
            
            return HttpContext.Current.Session[UserKey] as User;

        }

        public string LastAction
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public void Clear()
        {
            HttpContext.Current.Session.Clear();
        }

        public void UpdateUser(User user)
        {
            HttpContext.Current.User = user;
            HttpContext.Current.Session[UserKey] = user;
        }

        public User CurrentUser
        {
            get { return HttpContext.Current.Session[UserKey] as User; }
            set
            {
                HttpContext.Current.User = value;
                HttpContext.Current.Session[UserKey] = value;
            }
        }
    }
}